package cz.muni.fi.pa165.library.api;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 *
 * @author Filip Ligac
 */
public class BorrowTO implements Serializable {

    private static final long serialVersionUID = 40L;
    private Long borrowID;
    private ReaderTO readerTO;
    private List<BookTO> titlesTO;
    private Date borrowDate;
    private Date expirationDate;

    public BorrowTO() {
    }

    public BorrowTO(ReaderTO readerTO, List<BookTO> titlesTO, Date borrowDate, Date expirationDate) {
        this.readerTO = readerTO;
        this.titlesTO = titlesTO;
        this.borrowDate = borrowDate;
        this.expirationDate = expirationDate;
    }

    public void setBorrowID(Long borrowID) {
        this.borrowID = borrowID;
    }

    public void setReaderTO(ReaderTO readerTO) {
        this.readerTO = readerTO;
    }

    public void setTitlesTO(List<BookTO> titlesTO) {
        this.titlesTO = titlesTO;
    }

    public void setBorrowDate(Date borrowDate) {
        this.borrowDate = borrowDate;
    }

    public void setExpirationDate(Date expirationDate) {
        this.expirationDate = expirationDate;
    }

    public Long getBorrowID() {
        return borrowID;
    }

    public ReaderTO getReaderTO() {
        return readerTO;
    }

    public List<BookTO> getTitlesTO() {
        return titlesTO;
    }

    public Date getBorrowDate() {
        return borrowDate;
    }

    public Date getExpirationDate() {
        return expirationDate;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 89 * hash + (this.borrowID != null ? this.borrowID.hashCode() : 0);
        hash = 89 * hash + (this.readerTO != null ? this.readerTO.hashCode() : 0);
        hash = 89 * hash + (this.titlesTO != null ? this.titlesTO.hashCode() : 0);
        hash = 89 * hash + (this.borrowDate != null ? this.borrowDate.hashCode() : 0);
        hash = 89 * hash + (this.expirationDate != null ? this.expirationDate.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof BorrowTO)) {
            return false;
        }
        BorrowTO other = (BorrowTO) object;
        if (this.readerTO == null || !this.readerTO.equals(other.readerTO)) {
            return false;
        }
        if (this.titlesTO == null || !this.titlesTO.equals(other.titlesTO)) {
            return false;
        }
        if (this.borrowDate == null || !this.borrowDate.equals(other.borrowDate)) {
            return false;
        }
        if (this.expirationDate == null || !this.expirationDate.equals(other.expirationDate)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Borrow[ readerID = " + readerTO + ", titleID = " + titlesTO + " ]";
    }
}